package com.example.controller;

import com.example.model.dto.Result;
import com.example.model.vo.OrderShippingVO;
import com.example.service.IShippingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: backend
 * @author: zk
 * @create: 2023-04-23 16:03
 **/
@Slf4j
@RestController
@RequestMapping("/shippings")
@Api(tags = "地址信息管理")
public class ShippingController {
    @Resource
    private IShippingService shippingService;

    /**
     * 添加地址
     */
    @ApiOperation("添加地址")
    @PostMapping
    private Result addShipping(@RequestBody OrderShippingVO orderShippingVO) {
        return shippingService.addShipping(orderShippingVO);
    }

    @ApiOperation("删除地址")
    @DeleteMapping("{id}")
    private Result deleteShipping(@PathVariable String id) {
        return shippingService.deleteShipping(id);
    }

    @ApiOperation("更新地址")
    @PutMapping("{id}")
    private Result updateShipping(@PathVariable String id, @RequestBody OrderShippingVO orderShippingVO) {
        return shippingService.updateShipping(id, orderShippingVO);
    }

    @ApiOperation("获取地址")
    @PutMapping()
    private Result updateShipping() {
        return shippingService.getShipping();
    }


}
